<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2020 the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See docs/COPYRIGHT.rdoc for more details.

++#%>

<% cost_types = @cost_types.select(&:deleted_at) -%>

<% if cost_types.empty? %>
  <%= no_results_box %>
<% else %>
  <div class="generic-table--container">
    <div class="generic-table--results-container">
      <table class="generic-table locked_cost_types">
        <colgroup>
          <col highlight-col>
          <col highlight-col>
          <col highlight-col>
          <col highlight-col>
          <col highlight-col>
          <col>
        </colgroup>
        <thead>
          <tr>
            <%= sort_header_tag("name", :caption => CostType.model_name.human) %>
            <%= sort_header_tag("unit", :caption => CostType.human_attribute_name(:unit)) %>
            <%= sort_header_tag("unit_plural", :caption => CostType.human_attribute_name(:unit_plural)) %>
            <th>
              <div class="generic-table--sort-header-outer">
                <div class="generic-table--sort-header">
                  <span>
                    <%= CostType.human_attribute_name(:current_rate) %>
                  </span>
                </div>
              </div>
            </th>
            <th>
              <div class="generic-table--sort-header-outer">
                <div class="generic-table--sort-header">
                  <span>
                    <%= t(:caption_locked_on) %>
                  </span>
                </div>
              </div>
            </th>
            <th><div class="generic-table--empty-header"></div></th>
          </tr>
          </thead>
          <tbody>
            <% cost_types.each do |cost_type| %>
              <tr>
                <%= content_tag :td, cost_type.name %>
                <%= content_tag :td, cost_type.unit %>
                <%= content_tag :td, cost_type.unit_plural %>
                <%= content_tag :td, to_currency_with_empty(cost_type.rate_at(@fixed_date)), :class => "currency" %>
                <%= content_tag :td, cost_type.deleted_at.to_date %>
                <td class="buttons">
                  <%= form_for cost_type, url: restore_cost_type_path(cost_type),
                                          method: :patch,
                                          html: { id: "restore_cost_type_#{cost_type.id}",
                                                  class: 'restore_cost_type' } do |f| %>
                    <button type="submit"
                            class="button--link submit_cost_type">
                      <%= icon_wrapper('icon icon-unlocked', I18n.t(:button_unlock)) %>
                    </button>
                  <% end %>
                </td>
              </tr>
            <% end %>
          </tbody>
        </table>

      </div>
    </div>
<% end %>
